﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TinyCinema.UI
{
    /// <summary>
    /// Interaction logic for Setting.xaml
    /// </summary>
    public partial class ServerLogin : Window
    {
        public static Bussiness.Login.ServerLogin dataContext = new Bussiness.Login.ServerLogin();
        public ServerLogin()
        {
            InitializeComponent();
            dataContext.Messenger.Register<Bussiness.Login.Message.ConnectionOK>(this, (s) =>
            {
                this.Close();
                (new SampleDataInstaller()).ShowDialog();
            });
            dataContext.Messenger.Register<Bussiness.Login.Message.ConnectionError>(this, (s) =>
            {
                MessageBoxUtils.WPFMessageBox.Show("Không thể kết nối tới sever", "", MessageBoxButton.OK);
            });
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        private void Cancel(object sender, RoutedEventArgs e)
        {
            App.Current.Shutdown();
        }

        private void Login(object sender, RoutedEventArgs e)
        {
            (DataContext as Bussiness.Login.ServerLogin).Password = pbxInput.Password;
        }
    }
}
